//
//  MYNewsParentingListCell.m
//  MuYing
//
//  Created by tbb on 2019/8/2.
//  Copyright © 2019 TBB. All rights reserved.
//

#import "MYNewsParentingListCell.h"
#import "MYNewsParentingListCollCell.h"
#import "MYNewsDetailsScenicspotVC.h"
@interface MYNewsParentingListCell ()<UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView * goodsCollView;
@end

@implementation MYNewsParentingListCell

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.contentView addSubview:self.goodsCollView];
    [self.goodsCollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.bottom.mas_equalTo(-18);
        make.top.mas_equalTo(18);
    }];
}

#pragma makr -- lazy
-(UICollectionView *) goodsCollView{
    if (!_goodsCollView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        layout.minimumLineSpacing = 15;
        
        //CGFloat cw = floor((((kScreenWidth - 54) - 260) / 3.0));
        layout.minimumInteritemSpacing = 0.001;
        layout.itemSize = CGSizeMake(kNEWS_PARENTING_LIST_IMAGE_H
                                     , kNEWS_PARENTING_LIST_H);
        _goodsCollView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
        _goodsCollView.delegate = self;
        _goodsCollView.dataSource = self;
        _goodsCollView.bounces = false;
        _goodsCollView.showsVerticalScrollIndicator = NO;
        _goodsCollView.backgroundColor = UIColor.whiteColor;
        _goodsCollView.scrollEnabled = NO;
        [_goodsCollView registerClass:[MYNewsParentingListCollCell class] forCellWithReuseIdentifier:@"MYNewsParentingListCollCell"];
    }
    return _goodsCollView;
}
#pragma makr -- lazy end
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 3;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    MYNewsParentingListCollCell *collCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MYNewsParentingListCollCell" forIndexPath:indexPath];
    collCell.titleLb.text = @"深圳世界之窗门票需要通本人港澳….";
    collCell.priceLb.text = [NSString stringWithFormat:@"%@%@",@"400",kYQLS(@"起")];//@"$400起";
    return collCell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    MYNewsDetailsScenicspotVC * vc = [[MYNewsDetailsScenicspotVC alloc] init];

    [self.navVC pushViewController:vc animated:true];
}
@end
